<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>详情</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap"
		 rel="stylesheet">
		<link rel="shortcut icon" type="image/x-icon" href="../../assetsimages/x-icon/agricul.png">
		<link rel="stylesheet" href="../../assets/css/relys/animate.css">
		<link rel="stylesheet" href="../../assets/css/relys/bootstrap.min.css">
		<link rel="stylesheet" href="../../assets/css/relys/all.min.css">
		<link rel="stylesheet" href="../../assets/css/relys/icofont.min.css">
		<link rel="stylesheet" href="../../assets/css/relys/lightcase.css">
		<link rel="stylesheet" href="../../assets/css/relys/swiper.min.css">
		<link rel="stylesheet" href="../../assets/css/relys/style.css">
		<style type="text/css">
			.shop-thumb {
				height: 0;
				padding-top: 100%;
				position: relative;
				overflow: hidden;
			}
			
			.shop-thumb img {
				width: 100%;
				position: absolute;
				top: 0;
				object-fit: cover;
				height: 100%;
				left: 0;
			}
			.description img{
				width: 100%;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<!-- Page Header Section Start Here -->
			<section class="page-header bg_img padding-tb">
				<div class="overlay"></div>
				<div class="container">
					<div class="page-header-content-area">
						<h4 class="ph-title">求职者信息评论表详情</h4>
						<ul class="agri-ul">
							<li><a href="../../index.html">首页</a></li>
							<li><a class="active">求职者信息评论表详情</a></li>
						</ul>
					</div>
				</div>
			</section>
			<!-- Page Header Section Ending Here -->
			<!-- Shop Page Section start here -->
			<section class="shop-single padding-tb">
				<div class="container">
					<div class="row justify-content-center">
						<div class="col-lg-10 col-12 sticky-widget">
							<div class="product-details">
								<div class="row">
									<div class="col-md-6 col-12">
										<div class="post-content" v-if="detail">
											<h4>关联表id：{{detail.refid}}</h4>
											<h4>评论内容：{{detail.content}}</h4>
											<h4>用户id：{{detail.userid}}</h4>

											<div class="form">
											</div>

										</div>
									</div>
								</div>
							</div>
							<div class="review">
								<ul class="agri-ul review-nav">
									<li :class="['rev', !hsdetail?'active':'']" data-target="review-content-show">评论 {{comments.length}}</li>
								</ul>
								<div :class="['review-content', hsdetail?'description-show':'review-content-show']">
									<div class="review-showing">
									    <ul class="agri-ul content">
									        <li v-for="(item, i) in comments" :key="i">
									            <div class="post-thumb">
									                <img src="../../assets/images/author.jpg" alt="shop">
									            </div>
									            <div class="post-content">
									                <div class="entry-meta">
									                    <div class="posted-on">
									                        <a>******</a>
									                    </div>
									                </div>
									                <div class="entry-content">
									                    <p>{{item.content}}</p>
									                </div>
									            </div>
									        </li>
									    </ul>
									    <div class="client-review">
									        <div class="review-form">
									            <div class="review-title">
									                <h5>您的评论</h5>
									            </div>
									            <form @submit.prevent="onCommentTap" class="row">
									                <div class="col-md-12 col-12">
									                    <textarea v-model="comment" rows="8" placeholder="请填写评论"></textarea>
									                </div>
									                <div class="col-12">
									                    <button class="defult-btn" type="submit">提交</button>
									                </div>
									            </form>
									        </div>
									    </div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>
		</div>
		<script src="../../assets/js/relys/jquery.js"></script>
		<script src="../../assets/js/relys/fontawesome.min.js"></script>
		<script src="../../assets/js/relys/waypoints.min.js"></script>
		<script src="../../assets/js/relys/bootstrap.min.js"></script>
		<script src="../../assets/js/relys/wow.min.js"></script>
		<script src="../../assets/js/relys/jquery.countdown.min.js"></script>
		<script src="../../assets/js/relys/jquery.counterup.min.js"></script>
		<script src="../../assets/js/relys/isotope.pkgd.min.js"></script>
		<script src="../../assets/js/relys/lightcase.js"></script>
		<script src="../../assets/js/relys/vue.js"></script>
		<script src="../../assets/js/api/api.js"></script>
		<script src="../../assets/js/api/tplist.js"></script>
		<script src="../../assets/js/api/shop-cart.js"></script>
		<script src="../../assets/js/api/defaultuser.js"></script>
		<script src="../../assets/js/relys/utils.js"></script>
		<div id="script"></div>
	</body>
	<script type="text/javascript">
			var app = new Vue({
				el: "#app",
				data: {
					id: "",
					buynum: 1,
					detail: null,
					swiperList: [],
					curImg: '',
					hsdetail: false,
					comments: [],
					comment: "",
					buttons: [],
				},
				async created() {
					var frontmenus = JSON.parse(localStorage.getItem("daohangmenus"))
					if(typeof frontmenus == "object"){
						frontmenus.forEach(item => {
							if(item.menutable == "discussqiuzhizhexinxi"){
								this.buttons = item.buttons
							}
						})
					}
					var id = getParam('id')
					this.id = id
					

					await this.getDetail(id)
					this.getComments()
					var scripts = [
						"../../assets/js/relys/swiper.min.js",
						"../../assets/js/relys/functions.js"
					]
					setTimeout(() => {
						scripts.forEach(ele => {
							var new_element=document.createElement("script");
							new_element.setAttribute("type","text/javascript");
							new_element.setAttribute("src",ele);// 在这里引入了a.js
							$('#script').append(new_element);
						})
					}, 500)
				},
				methods: {
					download(file){
					  window.open(file)
					},
					buynumDec(){
						if(this.buynum!=1){
							this.buynum--
						}
					},
					buynumInc(){
						this.buynum++
					},
					getSession(){
						return new Promise((resolve) => {
							var tablename = localStorage.getItem("sessionTable")
							session(`${tablename}`, (data) => {
								if(data&&data.code==0){
									resolve(data.data)
								}
							})
						})
					},
					addCart(){
						var _this = this;
						console.log(localStorage.getItem(`cart${this.detail.id}`));
						if (localStorage.getItem(`cart${this.detail.id}`)) {
							alert('该商品已添加到购物车')
							return
						}
						cartSave({
							tablename: 'discussqiuzhizhexinxi',
							goodid: this.detail.id,
							picture: this.swiperList[0],
							buynumber: this.buynum,
							price: this.detail.price,
							discountprice: this.detail.price
						}, function(res) {
							localStorage.setItem(`cart${_this.detail.id}`, true);
							alert('添加到购物车成功')
						});
					},
					onBuyTap() {
						let orderGoods = [];
						// 跳转到下单页面,需要购买的数据保存在缓存
						localStorage.setItem('orderGoods', JSON.stringify([{
							tablename: 'discussqiuzhizhexinxi',
							goodid: this.detail.id,
							picture: this.swiperList[0],
							buynumber: this.buynum,
							price: this.detail.price,
							discountprice: this.detail.price
						}]))
						// 跳转到支付页面
						window.location.href = '../order/confirm-order.html';
					},
					
					getDetail(id){
						return new Promise((resolve) => {
							goodsInfo('discussqiuzhizhexinxi',id, (res) => {
								this.detail = res.data
								this.$nextTick(() => {
									
									resolve(res)
								})
							})
						})
					},
					getComments(){
						commentList("discussqiuzhizhexinxi", this.detail.id, (res) => {
							if(res&&res.code==0){
								this.comments = res.data.list
							}
						})
					},

					async onCommentTap(){
						var user = await this.getSession()
						if(user){
							var data = {
								refid: this.detail.id,
								content: this.comment,
								userid: user.id 
							}
							addComment("discussqiuzhizhexinxi", data, (res) => {
								if(res&&res.code==0){
									alert("评论成功")
									this.getComments()
								}
							})
						}else{
							alert("评论失败")
						}
					},
				}
			})
	</script>
</html>
